/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package datas;

import beans.category;
import beans.customer;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author havn
 */
public class CustomersObj {
    private connect con;
    
    public CustomersObj() {
        con = new connect();
    }
    
    public Vector<customer> getList() {
        Vector v = new Vector();
        try {
            PreparedStatement state = con.getCon().prepareStatement("select top 50 * from Customers");
            ResultSet rs = state.executeQuery();
            while (rs.next()) { 
                v.add(new customer(rs.getString("CustomerID") , rs.getString("ContactName")
                        ,rs.getString("ContactTitle"), rs.getString("Address"), rs.getString("City")));
            }
        } catch (SQLException ex) { 
            Logger.getLogger(CategoriesObj.class.getName()).log(Level.SEVERE, null, ex);
        }
        return v;
    }
    
    public void ExportData(){
        XMLDom xml = new XMLDom();
        xml.write(getList());
    }
}
